/*
 * Copyright (c) 2016年12月12日 by XuanWu Wireless Technology Co.Ltd. 
 *             All rights reserved                         
 */
package com.iqiao.common.web.result;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @author crazywen
 * @version 1.0.0
 * @Description
 * @date 2016-12-12
 */
public class PageResult extends JsonResult {

    private Map<String, Object> data = new HashMap<>();

    public PageResult(long total, Object data) {
        super();
        this.data.put("total", total);
        this.data.put("data", data);
    }

    public PageResult(int total, Object data, String message) {
        super(ReturnCode.SUCCESS, message);
        this.data.put("total", total);
        this.data.put("data", data);
    }

    public static PageResult emptyResult() {
        return new PageResult(0, Collections.EMPTY_LIST);
    }

    public static PageResult success(long total, Object data) {
        return new PageResult(total, data);
    }

    public static PageResult success(int total, Object data, String message) {
        return new PageResult(total, data, message);
    }

    @Override
    public Map<String, Object> getData() {
        return data;
    }

    @Override
    public void setData(Object data) {
        super.setData(data);
    }
}
